// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import axios from "axios";
import qs from "qs";
import $ from "jquery";
import VueCookies from "vue-cookies";

import JSMpeg from "@/assets/js/jsmpeg.min.js";

Vue.config.productionTip = false;

Vue.use(ElementUI);
Vue.use(VueCookies);
Vue.prototype.$ = $;

Vue.prototype.$apiUrl = "/api";

let service = axios.create({
  baseURL: Vue.prototype.$apiUrl,
  transformRequest: [data => qs.stringify(data)]
});
service.interceptors.request.use(
  config => {
    let _t = Vue.prototype.$cookies.get("_t");
    if (_t) {
      config.headers._t = _t;
    }
    return config;
  },
  err => {
    return Promise.reject(err);
  }
);
Vue.prototype.$axios = service;
Vue.prototype.$qs = qs;

Vue.prototype.$JSMpeg = JSMpeg;

/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  components: { App },
  template: "<App/>"
});
